var _n42;
var cc__extends = __extends;
var cc__decorate = __decorate;
var cc__importDefault = __importDefault;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $1$yyComponent = require("yyComponent");
var s = cc__importDefault($1$yyComponent);
var $GameEventType = require("GameEventType");
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_TipMessage = function (t) {
  function _ctor() {
    const instance = null !== t && t.apply(this, arguments) || this; // 使用更具描述性的变量名

    // 初始化属性
    instance.msg = null;
    instance.tipNode = null;
    instance.action = null;

    return instance; // 返回实例
  }
  cc__extends(_ctor, t);
  _ctor.prototype.onLoad = function () {
    this.init();
  };
  _ctor.prototype.init = function () {
    // 设置提示节点
    this.tipNode = this.node;

    // 创建动作序列，包括延迟、渐隐和回调函数
    this.action = cc.sequence(
      cc.delayTime(1),          // 延迟 1 秒
      cc.fadeOut(0.5),         // 渐隐 0.5 秒
      cc.callFunc(this.onFadeOut, this) // 动作完成后调用 onFadeOut 方法
    );

    // 设置消息内容为空
    this.setMsg("");

    // 处理事件
    this.onEvents();

    // 隐藏当前节点
    this.hide();
  };
  _ctor.prototype.onEvents = function () {
    this.on($GameEventType.EventType.UIEvent.showTip, this.show, this);
  };
  _ctor.prototype.reset = function () {
    this.tipNode.active = true;
    this.tipNode.stopAllActions();
    this.tipNode.opacity = 0;
  };
  _ctor.prototype.show = function (_msg) {
    this.reset();
    this.node.active = true;
    this.setMsg(_msg);
    this.scheduleOnce(this.play.bind(this), 0);
  };
  _ctor.prototype.hide = function () {
    this.node.active = false;
  };
  _ctor.prototype.setMsg = function (str) {
    this.msg.string = str;
  };
  _ctor.prototype.play = function () {
    this.tipNode.opacity = 255;
    this.tipNode.runAction(this.action);
  };
  _ctor.prototype.onFadeOut = function () {
    this.hide();
  };
  cc__decorate([ccp_property(cc.Label)], _ctor.prototype, "msg", undefined);
  return cc__decorate([ccp_ccclass], _ctor);
}(s.default);
exports.default = def_TipMessage;